package com.df.springmvc.common.bean;

import java.util.ArrayList;

/**
 * @author David
 *         <rows>
 *         <head>
 *         <column width="50" type="ed" align="right" color="white" sort="str">Sales</column>
 *         <column width="80" type="co" align="left" sort="str">
 *         <option value="1">1 Day</option>
 *         <option value="7">1 Week</option>
 *         ...
 *         </column>
 *         <beforeInit>
 *         <call command="methodName"><param>string value</param></call>
 *         <call command="setSkin"><param>xp</param></call>
 *         </beforeInit>
 *         <afterInit>
 *         <call command="methodName">
 *         <param>string value</param>
 *         </call>
 *         </afterInit>
 *         <settings>
 *         <colwidth>%</colwidth> //'says' to use width in percents instead of pixels
 *         </settings>
 *         </head>
 *         <row>
 *         <cell>value1</cell>
 *         <cell>value2</cell>
 *         </row>
 *         </rows>
 */
public class DhtmlGridFieldBean{
	/**
	 * a simple editable cell;
	 */
	public final static String TYPE_ED="ed";
	/**
	 * an editable numeric cell that allows formatting values through the setNumberFormat method
	 */
	public final static String TYPE_EDN="edn";
	/**
	 * an editable text cell that treats data values as plain text, so HTML isn't allowed and any special char must be set without escaping;
	 */
	public final static String TYPE_EDTXT="edtxt";
	/**
	 * a simple read-only cell without the possibility to edit the content;
	 */
	public final static String TYPE_RO="ro";
	/**
	 * a read-only text cell that treats data values as plain text, so HTML isn't allowed and any special char must be set without escaping;
	 */
	public final static String TYPE_ROTXT="rotxt";
	/**
	 * a read-only numeric cell that allows formatting values through the setNumberFormat method.
	 */
	public final static String TYPE_RON="ron";
	/**
	 * a simple multi-line editor;
	 */
	public final static String TYPE_TXT="txt";
	/**
	 * a multi-line editor that treats data values as plain text, so HTML isn't allowed and any special char must be set without escaping.
	 */
	public final static String TYPE_TXTTXT="txttxt";
	/**
	 * a column-oriented radio button;
	 */
	public final static String TYPE_RA="ra";
	/**
	 * a row-oriented radio button.
	 */
	public final static String TYPE_RA_STR="ra_str";
	/**
	 * A simple check box.
	 */
	public final static String TYPE_CH="ch";
	/**
	 * an editable select box;
	 */
	public final static String TYPE_CO="co";
	/**
	 * a not editable select box;
	 */
	public final static String TYPE_CORO="coro";
	/**
	 * an editable select box presented by DHTMLX combo;
	 */
	public final static String TYPE_COMBO="combo";
	/**
	 * a multi- selection select box.
	 */
	public final static String TYPE_CLIST="clist";
	/**
	 * a simple date picker (presented by the DHTMLX calendar);
	 */
	public final static String TYPE_DHXCALENDAR="dhxCalendar";
	/**
	 * a date picker with a possibility to input date manually (presented by the DHTMLX calendar).
	 */
	public final static String TYPE_DHXCALENDARA="dhxCalendarA";
	/**
	 * A simple color picker.
	 */
	public final static String TYPE_CP="cp";
	/**
	 * An editor that treats data as link sources and renders them as links (analogous to the <a> HTML tag).
	 * specified as a '^'-delimited list
	 * text - the link text;
	 * url - (optional) the URL of the page the link goes to (without quotes) or some javascript function(javascript:function(param1,param2){...};);
	 * target - (optional) the target attribute specifying where to open the linked document.
	 * _blank - opens the link in a new window or tab (by default);
	 * _self - opens the link in the same frame as it was clicked;
	 * _parent - opens the link in the parent frame;
	 * _top - opens the link in the full body of the window.
	 * <cell>Link^javascript:alert(1);^_top</cell>// link to a function
	 */
	public final static String TYPE_LINK="link";
	/**
	 * An editor that treats data as the image source and renders them as images (analogous to the <img> HTML tag).
	 * url - (mandatory) the URL of an image;
	 * alt - (optional) an alternate text for an image;
	 * link - (optional) the URL of the page you will go to after clicking on image (without quotes) or some javascript function that will be invoked;
	 * target - (optional) the target attribute specifying where to open the linked page.
	 * _blank - opens the link in a new window or tab (by default);
	 * _self - opens the link in the same frame as it was clicked;
	 * _parent - opens the link in the parent frame;
	 * _top - opens the link in the full body of the window.
	 * <cell>icons/open_icon.png^DHTMLX site^http://dhtmlx.com^_self</cell>
	 */
	public final static String TYPE_IMG="img";
	/**
	 * An editor that treats data as price: values < 0 - rendered in green, values > 0 - rendered in red.
	 */
	public final static String TYPE_PRICE="price";
	/**
	 * An editor applies different colouring and marking based on the value. Intented for using with the sales data.
	 */
	public final static String TYPE_DYN="dyn";
	/**
	 * A popup calculator. Takes the format set by the setNumberFormat method.
	 */
	public final static String TYPE_CALCK="calck";
	/**
	 * An editor uses DHTMLX menu as an editor for a cell.
	 */
	public final static String TYPE_CONTEXT="context";
	/**
	 * An editor uses DHTMLX tree as an editor for a cell.
	 */
	public final static String TYPE_STREE="stree";
	/**
	 * An editor uses DHTMLX grid as an editor for a cell.
	 */
	public final static String TYPE_GRID="grid";
	/**
	 * 列向右合并
	 */
	public final static String ATTACH_SPAN_COLUMN="#cspan";
	/**
	 * 行向下合并
	 */
	public final static String ATTACH_SPAN_ROW="#rspan";
	/**
	 * 数据左对齐
	 */
	public final static String ALIGN_LEFT="left";
	/**
	 * 数据居中
	 */
	public final static String ALIGN_CENTER="center";
	/**
	 * 数据右对齐
	 */
	public final static String ALIGN_RIGHT="right";
	/**
	 * 数据上对齐
	 */
	public final static String VALIGN_TOP="top";
	/**
	 * 数据中对齐baseline,sub,super,,text-top,,,text-bottom
	 */
	public final static String VALIGN_MIDDLE="middle";
	/**
	 * 数据下对齐
	 */
	public final static String VALIGN_BOTTOM="bottom";
	/**
	 * 字符排序
	 */
	public final static String SORT_STR="str";
	/**
	 * 数据排序
	 */
	public final static String SORT_INT="int";
	/**
	 * 日期排序
	 */
	public final static String SORT_DATE="date";
	/**
	 * 与数据库一一对应
	 */
	public String id="";
	/**
	 * 表头
	 */
	public String header="";
	/**
	 * <afterInit>
	 * <call command="attachHeader"><param>A1,B1,C1</param></call>
	 * <call command="attachHeader"><param>A2,B2,C2</param></call>
	 * </afterInit>
	 */
	public String attachHeader="";
	/**
	 * <afterInit>
	 * <call command="attachFooter"><param>AF,BF,CF</param></call>
	 * </afterInit>
	 */
	public String attachFooter="";
	/**
	 * <afterInit>
	 * <call command="attachHeader"><param>A1,B1,C1</param></call>
	 * <call command="attachHeader"><param>A2,B2,C2</param></call>
	 * </afterInit>
	 */
	public String attachHeader2="";
	/**
	 * <afterInit>
	 * <call command="attachFooter"><param>AF,BF,CF</param></call>
	 * </afterInit>
	 */
	public String attachFooter2="";
	/**
	 * <afterInit>
	 * <call command="attachHeader"><param>A1,B1,C1</param></call>
	 * <call command="attachHeader"><param>A2,B2,C2</param></call>
	 * </afterInit>
	 */
	public String attachHeader3="";
	/**
	 * <afterInit>
	 * <call command="attachFooter"><param>AF,BF,CF</param></call>
	 * </afterInit>
	 */
	public String attachFooter3="";
	/**
	 * 
	 */
	public String type=TYPE_ED;
	public String align=ALIGN_LEFT;
	public String vAlign=VALIGN_MIDDLE;
	public String sort=SORT_STR;
	public String minMidth="100";
	public String width;
	public String maxMidth;
	public ArrayList<String> optionList=new ArrayList<String>();
	
	/**
	 * 只传入value时，key默认与value一样
	 * @param value
	 * @throws Exception
	 */
	public void addOption(String value) throws Exception{
		addOption(value,value);
	}
	/**
	 * 传入key时与value时，保存为key-value对的方式
	 * @param key
	 * @param value
	 * @throws Exception
	 */
	public void addOption(String key,String value) throws Exception{
		if(key == null){
			throw new Exception("optionkey不能为null");
		}
		if(value == null){
			throw new Exception("optionvalue不能为ull");
		}
		if((key + "" + value).contains(":")){
			throw new Exception("key与value中禁止使用:号");
		}
		String temp=key + ":" + value;
		if(!optionList.contains(key + ":")){
			optionList.add(temp);
		}else{
			org.apache.log4j.Logger.getLogger(getClass()).warn("重复增加option");
		}
	}
	public void clearOption(){
		optionList.clear();
	}
	public DhtmlGridFieldBean(String id,String header){
		// TODO Auto-generated constructor stub
		this.id=id;
		this.header="<center>" + header + "</center>";
	}
	public DhtmlGridFieldBean(String id,String header,String type){
		// TODO Auto-generated constructor stub
		this.id=id;
		this.header="<center>" + header + "</center>";
		this.type=type;
	}
	public DhtmlGridFieldBean(String id,String header,String type,String width){
		// TODO Auto-generated constructor stub
		this.id=id;
		this.header="<center>" + header + "</center>";
		this.type=type;
		this.width=width;
	}
	public DhtmlGridFieldBean(String id,String header,String type,String width,String align){
		// TODO Auto-generated constructor stub
		this.id=id;
		this.header="<center>" + header + "</center>";
		this.type=type;
		this.align=align;
		this.width=width;
	}
	public DhtmlGridFieldBean(String id,String header,String type,String width,String align,String sort){
		// TODO Auto-generated constructor stub
		this.id=id;
		this.header="<center>" + header + "</center>";
		this.type=type;
		this.align=align;
		this.sort=sort;
		this.width=width;
	}
	public DhtmlGridFieldBean(String id,String header,String type,String width,String align,String sort,String minMidth){
		// TODO Auto-generated constructor stub
		this.id=id;
		this.header="<center>" + header + "</center>";
		this.type=type;
		this.align=align;
		this.sort=sort;
		this.minMidth=minMidth;
		this.width=width;
	}
	/**
	 * @return the id
	 */
	public String getId(){
		return id;
	}
	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(String id){
		this.id=id;
	}
	/**
	 * @return the header
	 */
	public String getHeader(){
		return header;
	}
	/**
	 * @param header
	 *            the header to set
	 */
	public void setHeader(String header){
		this.header="<center>" + header + "</center>";
	}
	/**
	 * @return the type
	 */
	public String getType(){
		return type;
	}
	/**
	 * @param type
	 *            the type to set
	 */
	public void setType(String type){
		this.type=type;
	}
	/**
	 * @return the align
	 */
	public String getAlign(){
		return align;
	}
	/**
	 * @param align
	 *            the align to set
	 */
	public void setAlign(String align){
		this.align=align;
	}
	/**
	 * @return the sort
	 */
	public String getSort(){
		return sort;
	}
	/**
	 * @param sort
	 *            the sort to set
	 */
	public void setSort(String sort){
		this.sort=sort;
	}
	/**
	 * @return the minMidth
	 */
	public String getMinMidth(){
		return minMidth;
	}
	/**
	 * @param minMidth
	 *            the minMidth to set
	 */
	public void setMinMidth(String minMidth){
		this.minMidth=minMidth;
	}
	/**
	 * @return the width
	 */
	public String getWidth(){
		return width;
	}
	/**
	 * @param width
	 *            the width to set
	 */
	public void setWidth(String width){
		this.width=width;
	}
	/**
	 * @return the maxMidth
	 */
	public String getMaxMidth(){
		return maxMidth;
	}
	/**
	 * @param maxMidth
	 *            the maxMidth to set
	 */
	public void setMaxMidth(String maxMidth){
		this.maxMidth=maxMidth;
	}
	/**
	 * @return the typeEd
	 */
	public static String getTypeEd(){
		return TYPE_ED;
	}
	/**
	 * @return the typeEdn
	 */
	public static String getTypeEdn(){
		return TYPE_EDN;
	}
	/**
	 * @return the typeEdtxt
	 */
	public static String getTypeEdtxt(){
		return TYPE_EDTXT;
	}
	/**
	 * @return the typeRo
	 */
	public static String getTypeRo(){
		return TYPE_RO;
	}
	/**
	 * @return the typeRotxt
	 */
	public static String getTypeRotxt(){
		return TYPE_ROTXT;
	}
	/**
	 * @return the typeRon
	 */
	public static String getTypeRon(){
		return TYPE_RON;
	}
	/**
	 * @return the typeTxt
	 */
	public static String getTypeTxt(){
		return TYPE_TXT;
	}
	/**
	 * @return the typeTxttxt
	 */
	public static String getTypeTxttxt(){
		return TYPE_TXTTXT;
	}
	/**
	 * @return the typeRa
	 */
	public static String getTypeRa(){
		return TYPE_RA;
	}
	/**
	 * @return the typeRaStr
	 */
	public static String getTypeRaStr(){
		return TYPE_RA_STR;
	}
	/**
	 * @return the typeCh
	 */
	public static String getTypeCh(){
		return TYPE_CH;
	}
	/**
	 * @return the typeCo
	 */
	public static String getTypeCo(){
		return TYPE_CO;
	}
	/**
	 * @return the typeCoro
	 */
	public static String getTypeCoro(){
		return TYPE_CORO;
	}
	/**
	 * @return the typeCombo
	 */
	public static String getTypeCombo(){
		return TYPE_COMBO;
	}
	/**
	 * @return the typeClist
	 */
	public static String getTypeClist(){
		return TYPE_CLIST;
	}
	/**
	 * @return the typeDhxcalendar
	 */
	public static String getTypeDhxcalendar(){
		return TYPE_DHXCALENDAR;
	}
	/**
	 * @return the typeDhxcalendara
	 */
	public static String getTypeDhxcalendara(){
		return TYPE_DHXCALENDARA;
	}
	/**
	 * @return the typeCp
	 */
	public static String getTypeCp(){
		return TYPE_CP;
	}
	/**
	 * @return the typeLink
	 */
	public static String getTypeLink(){
		return TYPE_LINK;
	}
	/**
	 * @return the typeImg
	 */
	public static String getTypeImg(){
		return TYPE_IMG;
	}
	/**
	 * @return the typePrice
	 */
	public static String getTypePrice(){
		return TYPE_PRICE;
	}
	/**
	 * @return the typeDyn
	 */
	public static String getTypeDyn(){
		return TYPE_DYN;
	}
	/**
	 * @return the typeCalck
	 */
	public static String getTypeCalck(){
		return TYPE_CALCK;
	}
	/**
	 * @return the typeContext
	 */
	public static String getTypeContext(){
		return TYPE_CONTEXT;
	}
	/**
	 * @return the typeStree
	 */
	public static String getTypeStree(){
		return TYPE_STREE;
	}
	/**
	 * @return the typeGrid
	 */
	public static String getTypeGrid(){
		return TYPE_GRID;
	}
	/**
	 * @return the attachSpanColumn
	 */
	public static String getAttachSpanColumn(){
		return ATTACH_SPAN_COLUMN;
	}
	/**
	 * @return the attachSpanRow
	 */
	public static String getAttachSpanRow(){
		return ATTACH_SPAN_ROW;
	}
	/**
	 * @return the alignLeft
	 */
	public static String getAlignLeft(){
		return ALIGN_LEFT;
	}
	/**
	 * @return the alignCenter
	 */
	public static String getAlignCenter(){
		return ALIGN_CENTER;
	}
	/**
	 * @return the alignRight
	 */
	public static String getAlignRight(){
		return ALIGN_RIGHT;
	}
	/**
	 * @return the sortStr
	 */
	public static String getSortStr(){
		return SORT_STR;
	}
	/**
	 * @return the sortInt
	 */
	public static String getSortInt(){
		return SORT_INT;
	}
	/**
	 * @return the sortDate
	 */
	public static String getSortDate(){
		return SORT_DATE;
	}
	/**
	 * @return the valign
	 */
	public String getVAlign(){
		return vAlign;
	}
	/**
	 * @param valign
	 *            the valign to set
	 */
	public void setValign(String vAlign){
		this.vAlign=vAlign;
	}
	/**
	 * @return the valignTop
	 */
	public static String getValignTop(){
		return VALIGN_TOP;
	}
	/**
	 * @return the valignMiddle
	 */
	public static String getValignMiddle(){
		return VALIGN_MIDDLE;
	}
	/**
	 * @return the valignBottom
	 */
	public static String getValignBottom(){
		return VALIGN_BOTTOM;
	}
	/**
	 * @return the vAlign
	 */
	public String getvAlign(){
		return vAlign;
	}
	/**
	 * @param vAlign
	 *            the vAlign to set
	 */
	public void setvAlign(String vAlign){
		this.vAlign=vAlign;
	}
	/**
	 * @return the attachHeader
	 */
	public String getAttachHeader(){
		return attachHeader;
	}
	/**
	 * @param attachHeader
	 *            the attachHeader to set
	 */
	public void setAttachHeader(String attachHeader){
		this.attachHeader=attachHeader;
	}
	/**
	 * @return the attachFooter
	 */
	public String getAttachFooter(){
		return attachFooter;
	}
	/**
	 * @param attachFooter
	 *            the attachFooter to set
	 */
	public void setAttachFooter(String attachFooter){
		this.attachFooter=attachFooter;
	}
	/**
	 * @return the attachHeader2
	 */
	public String getAttachHeader2(){
		return attachHeader2;
	}
	/**
	 * @param attachHeader2
	 *            the attachHeader2 to set
	 */
	public void setAttachHeader2(String attachHeader2){
		this.attachHeader2=attachHeader2;
	}
	/**
	 * @return the attachFooter2
	 */
	public String getAttachFooter2(){
		return attachFooter2;
	}
	/**
	 * @param attachFooter2
	 *            the attachFooter2 to set
	 */
	public void setAttachFooter2(String attachFooter2){
		this.attachFooter2=attachFooter2;
	}
	/**
	 * @return the attachHeader3
	 */
	public String getAttachHeader3(){
		return attachHeader3;
	}
	/**
	 * @param attachHeader3
	 *            the attachHeader3 to set
	 */
	public void setAttachHeader3(String attachHeader3){
		this.attachHeader3=attachHeader3;
	}
	/**
	 * @return the attachFooter3
	 */
	public String getAttachFooter3(){
		return attachFooter3;
	}
	/**
	 * @param attachFooter3
	 *            the attachFooter3 to set
	 */
	public void setAttachFooter3(String attachFooter3){
		this.attachFooter3=attachFooter3;
	}
	public ArrayList<String> getOptionList(){
		return optionList;
	}
	public void setOptionList(ArrayList<String> optionList){
		this.optionList=optionList;
	}
}
